package top.likeqc.dto;

import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * 问卷答案 DTO
 * @author likeqc
 * @date 2022年04月22日 0:06
 */
@Data
public class AnswerDTO {

    /**
     * 学生学号
     */
    String studentNumber;

    /**
     * 学生姓名
     */
    String studentName;

    /**
     * 平均得分
     */
    Double average;

    List<Answer> answerList = new ArrayList<>();


    public void calcAverage() {
        double average = 0;
        if (null != answerList && answerList.size() > 0) {
            for (Answer answer : answerList) {
                average += answer.value;
            }
            average = average / answerList.size();
        }
        this.average = average;
    }

    @Data
    public static class Answer {
        public Answer(String content, Integer value) {
            this.content = content;
            this.value = value;
        }

        String content;
        Integer value;
    }
}
